from rest_framework import serializers
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin,CreateModelMixin,UpdateModelMixin,DestroyModelMixin
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from rest_framework.viewsets import GenericViewSet
from rest_framework.decorators import action
from api import models


class SixviewSerizer(serializers.ModelSerializer):
    class Meta:
        model = models.UserInfo
        fields = "__all__"

class SixView(ListModelMixin,CreateModelMixin,GenericViewSet):
    querset = models.UserInfo.objects.all().order_by('-id')
    # queryset = None
    serializer_class = SixviewSerizer
    @action(detail=False,methods=['get'],url_path='yyy/(?P<xx>\d+)/xxx')
    def get_password(self,request,xx,pk=None):
        return Response("hahahahah")
    # def list(self, request):
    #     #1.获取数据
    #     querset = self.get_queryset()
    #     #2.分页
    #     result = self.paginate_queryset(querset)
    #     #3.序列化
    #     ser = self.get_serializer(instance=result, many=True)
